#pragma once

#include <thrust/transform_reduce.h>

template <typename Container,
          typename UnaryOperation,
          typename T,
          typename BinaryOperation>
struct TransformReduce
{
  Container A;
  UnaryOperation unary_op;
  T init;
  BinaryOperation binary_op;

  template <typename Range>
  TransformReduce(const Range& X, UnaryOperation unary_op, T init, BinaryOperation binary_op)
    : A(X.begin(), X.end()),
      unary_op(unary_op),
      init(init),
      binary_op(binary_op)
  {}

  void operator()(void)
  {
    thrust::transform_reduce(A.begin(), A.end(), unary_op, init, binary_op);
  }
  
  void reset(void)
  {
    // nothing to do
  }
};

